unit GameContentGroupUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, DBGrids, DB, ADODB, Buttons;

type
  TfrmGameContentGroup = class(TForm)
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    DBGrid1: TDBGrid;
    DBGrid2: TDBGrid;
    QueryContent: TADOQuery;
    QueryGroup: TADOQuery;
    Query: TADOQuery;
    GroupBox3: TGroupBox;
    DBGrid3: TDBGrid;
    btnAdd: TBitBtn;
    BitBtn2: TBitBtn;
    btnClose: TBitBtn;
    ds: TDataSource;
    dsGroup: TDataSource;
    dsContent: TDataSource;
    QueryContentGameContentId: TIntegerField;
    QueryContentGameContentName: TStringField;
    QueryContentGameContentUrl: TStringField;
    QueryContentBrandId: TIntegerField;
    QueryBrand: TADOQuery;
    QueryBrandBrandId: TAutoIncField;
    QueryBrandBrandName: TStringField;
    QueryContentBrandName: TStringField;
    QueryGameGroupId: TIntegerField;
    QueryGameContentId: TIntegerField;
    QueryGameGroupName: TStringField;
    QueryGameContentName: TStringField;
    QueryGroupGameGroupId: TIntegerField;
    QueryGroupGameGroupName: TStringField;
    QueryGroupGameGroupUrl: TStringField;
    QueryGroupGameGroupMemo: TStringField;
    Query2: TADOQuery;
    Query1: TADOQuery;
    Query1GameContentId: TIntegerField;
    Query1GameContentName: TStringField;
    Query1GameContentUrl: TStringField;
    Query1BrandId: TIntegerField;
    Query2GameGroupId: TIntegerField;
    Query2GameGroupName: TStringField;
    Query2GameGroupUrl: TStringField;
    Query2GameGroupMemo: TStringField;
    procedure FormCreate(Sender: TObject);
    procedure btnAddClick(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmGameContentGroup: TfrmGameContentGroup;

implementation

uses FunctionUnit, GTMain;

{$R *.dfm}

procedure TfrmGameContentGroup.FormCreate(Sender: TObject);
begin
  OpenDataSet('SELECT * FROM Brand', QueryBrand, Database);
  OpenDataSet('SELECT * FROM GameContent', QueryContent, Database);
  OpenDataSet('SELECT * FROM GameContent', Query1, Database);
  OpenDataSet('SELECT * FROM GameGroup', QueryGroup, Database);
  OpenDataSet('SELECT * FROM GameGroup', Query2, Database);
//  OpenDataSet('SELECT * FROM GameClass', QueryClass, Database);
//  OpenDataSet('SELECT * FROM GameClass', Query3, Database);
  OpenDataSet('SELECT * FROM GameContentGroup', Query, Database);
end;

procedure TfrmGameContentGroup.btnAddClick(Sender: TObject);
begin
  if Query.Locate('GameContentId;GameGroupId', VarArrayOf([QueryContentGameContentId.Value, QueryGroupGameGroupId.Value]), []) then
    Exit;
    
  Query.Append;
  Query.FieldByName('GameContentId').Value := QueryContentGameContentId.Value;
  Query.FieldByName('GameGroupId').Value := QueryGroupGameGroupId.Value;
//  Query.FieldByName('GameClassId').Value := QueryClassGameClassId.Value;
  Query.CheckBrowseMode;
end;

procedure TfrmGameContentGroup.BitBtn2Click(Sender: TObject);
begin
  Query.Delete;
end;

end.
